package at.jku.se.fastsell.db4o;

/**
 * Generic exception class for database errors (invalid arguments, constraint violations, ...)
 */
public class DatabaseException extends Exception {

	private static final long serialVersionUID = 1L;
	
	private String message;
	private Exception originalException;

	// ----------------------------------------------------------------------------------

	public DatabaseException(String message) {
		this.message = message;
	}

	public DatabaseException(String message, Exception origin) {
		this(message);
		this.originalException = origin;
	}
	
	// ----------------------------------------------------------------------------------

	@Override
	public String getMessage() {
		if (originalException != null)
			return message + "\n\nOriginal message: " + originalException.getMessage();
		return message;
	}

}
